home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / xulrunner-10.0 / run-mozilla.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2013-01-09  |  10.1 KB  |  395 lines

  1. #!/bin/sh
  2. #
  3. # ***** BEGIN LICENSE BLOCK *****
  4. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. #
  6. # The contents of this file are subject to the Mozilla Public License Version
  7. # 1.1 (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. # http://www.mozilla.org/MPL/
  10. #
  11. # Software distributed under the License is distributed on an "AS IS" basis,
  12. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. # for the specific language governing rights and limitations under the
  14. # License.
  15. #
  16. # The Original Code is mozilla.org code.
  17. #
  18. # The Initial Developer of the Original Code is
  19. # Netscape Communications Corporation.
  20. # Portions created by the Initial Developer are Copyright (C) 1998
  21. # the Initial Developer. All Rights Reserved.
  22. #
  23. # Contributor(s):
  24. #
  25. # Alternatively, the contents of this file may be used under the terms of
  26. # either of the GNU General Public License Version 2 or later (the "GPL"),
  27. # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. # in which case the provisions of the GPL or the LGPL are applicable instead
  29. # of those above. If you wish to allow use of your version of this file only
  30. # under the terms of either the GPL or the LGPL, and not to allow others to
  31. # use your version of this file under the terms of the MPL, indicate your
  32. # decision by deleting the provisions above and replace them with the notice
  33. # and other provisions required by the GPL or the LGPL. If you do not delete
  34. # the provisions above, a recipient may use your version of this file under
  35. # the terms of any one of the MPL, the GPL or the LGPL.
  36. #
  37. # ***** END LICENSE BLOCK *****
  38. cmdname=`basename "$0"`
  39. MOZ_DIST_BIN=`dirname "$0"`
  40. MOZ_DEFAULT_NAME="./${cmdname}-bin"
  41. MOZ_APPRUNNER_NAME="./mozilla-bin"
  42. MOZ_PROGRAM=""
  43.  
  44. exitcode=1
  45. #
  46. ##
  47. ## Functions
  48. ##
  49. ##########################################################################
  50. moz_usage()
  51. {
  52. echo "Usage:  ${cmdname} [options] [program]"
  53. echo ""
  54. echo "  options:"
  55. echo ""
  56. echo "    -g                   Run in debugger."
  57. echo "    --debug"
  58. echo ""
  59. echo "    -d debugger          Debugger to use."
  60. echo "    --debugger debugger"
  61. echo ""
  62. echo "    -a debugger_args     Arguments passed to [debugger]."
  63. echo "    --debugger-args debugger_args"
  64. echo ""
  65. echo "  Examples:"
  66. echo ""
  67. echo "  Run the mozilla-bin binary"
  68. echo ""
  69. echo "    ${cmdname} mozilla-bin"
  70. echo ""
  71. echo "  Debug the mozilla-bin binary in gdb"
  72. echo ""
  73. echo "    ${cmdname} -g mozilla-bin -d gdb"
  74. echo ""
  75. echo "  Run mozilla-bin under valgrind with arguments"
  76. echo ""
  77. echo "    ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
  78. echo ""
  79.     return 0
  80. }
  81. ##########################################################################
  82. moz_bail()
  83. {
  84.     message=$1
  85.     echo
  86.     echo "$cmdname: $message"
  87.     echo
  88.     exit 1
  89. }
  90. ##########################################################################
  91. moz_test_binary()
  92. {
  93.     binary=$1
  94.     if [ -f "$binary" ]
  95.     then
  96.         if [ -x "$binary" ]
  97.         then
  98.             return 1
  99.         fi
  100.     fi
  101.     return 0
  102. }
  103. ##########################################################################
  104. moz_get_debugger()
  105. {
  106.     debuggers="ddd gdb dbx bdb native-gdb"
  107.     debugger="notfound"
  108.     done="no"
  109.     for d in $debuggers
  110.     do
  111.         moz_test_binary /bin/which
  112.         if [ $? -eq 1 ]
  113.         then
  114.             dpath=`which ${d}`    
  115.         else     
  116.             dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`    
  117.         fi
  118.         if [ -x "$dpath" ]
  119.         then
  120.             debugger=$dpath
  121.             break
  122.         fi
  123.     done
  124.     echo $debugger
  125.     return 0
  126. }
  127. ##########################################################################
  128. moz_run_program()
  129. {
  130.     prog=$MOZ_PROGRAM
  131.     ##
  132.     ## Make sure the program is executable
  133.     ##
  134.     if [ ! -x "$prog" ]
  135.     then
  136.         moz_bail "Cannot execute $prog."
  137.     fi
  138.     ##
  139.     ## Run the program
  140.     ##
  141.     exec "$prog" ${1+"$@"}
  142.     exitcode=$?
  143. }
  144. ##########################################################################
  145. moz_debug_program()
  146. {
  147.     prog=$MOZ_PROGRAM
  148.     ##
  149.     ## Make sure the program is executable
  150.     ##
  151.     if [ ! -x "$prog" ]
  152.     then
  153.         moz_bail "Cannot execute $prog."
  154.     fi
  155.     if [ -n "$moz_debugger" ]
  156.     then
  157.         moz_test_binary /bin/which
  158.         if [ $? -eq 1 ]
  159.         then    
  160.             debugger=`which $moz_debugger` 
  161.         else
  162.             debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'` 
  163.         fi    
  164.     else
  165.         debugger=`moz_get_debugger`
  166.     fi
  167.     if [ -x "$debugger" ] 
  168.     then
  169. # If you are not using ddd, gdb and know of a way to convey the arguments 
  170. # over to the prog then add that here- Gagan Saksena 03/15/00
  171.         case `basename $debugger` in
  172.             native-gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
  173.                 exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
  174.                 exitcode=$?
  175.                 ;;
  176.             gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
  177.                 exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
  178.         exitcode=$?
  179.                 ;;
  180.             ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
  181.         exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
  182.         exitcode=$?
  183.                 ;;
  184.             *) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
  185.                 exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
  186.         exitcode=$?
  187.                 ;;
  188.         esac
  189.     else
  190.         moz_bail "Could not find a debugger on your system."
  191.     fi
  192. }
  193. ##########################################################################
  194. ##
  195. ## Command line arg defaults
  196. ##
  197. moz_debug=0
  198. moz_debugger=""
  199. moz_debugger_args=""
  200. #
  201. ##
  202. ## Parse the command line
  203. ##
  204. while [ $# -gt 0 ]
  205. do
  206.   case $1 in
  207.     -g | --debug)
  208.       moz_debug=1
  209.       shift
  210.       ;;
  211.     -d | --debugger)
  212.       moz_debugger=$2;
  213.       if [ "${moz_debugger}" != "" ]; then
  214.     shift 2
  215.       else
  216.         echo "-d requires an argument"
  217.         exit 1
  218.       fi
  219.       ;;
  220.     -a | --debugger-args)
  221.       moz_debugger_args=$2;
  222.       if [ "${moz_debugger_args}" != "" ]; then
  223.     shift 2
  224.       else
  225.         echo "-a requires an argument"
  226.         exit 1
  227.       fi
  228.       ;;
  229.     *)
  230.       break;
  231.       ;;
  232.   esac
  233. done
  234. #
  235. ##
  236. ## Program name given in $1
  237. ##
  238. if [ $# -gt 0 ]
  239. then
  240.     MOZ_PROGRAM=$1
  241.     shift
  242. fi
  243. ##
  244. ## Program not given, try to guess a default
  245. ##
  246. if [ -z "$MOZ_PROGRAM" ]
  247. then
  248.     ##
  249.     ## Try this script's name with '-bin' appended
  250.     ##
  251.     if [ -x "$MOZ_DEFAULT_NAME" ]
  252.     then
  253.         MOZ_PROGRAM=$MOZ_DEFAULT_NAME
  254.     ##
  255.     ## Try mozilla-bin
  256.     ## 
  257.     elif [ -x "$MOZ_APPRUNNER_NAME" ]
  258.     then
  259.         MOZ_PROGRAM=$MOZ_APPRUNNER_NAME
  260.     fi
  261. fi
  262. #
  263. #
  264. ##
  265. ## Make sure the program is executable
  266. ##
  267. if [ ! -x "$MOZ_PROGRAM" ]
  268. then
  269.     moz_bail "Cannot execute $MOZ_PROGRAM."
  270. fi
  271. #
  272. ##
  273. ## Set MOZILLA_FIVE_HOME
  274. ##
  275. MOZILLA_FIVE_HOME=$MOZ_DIST_BIN
  276.  
  277. if [ -z "$MRE_HOME" ]; then
  278.     MRE_HOME=$MOZILLA_FIVE_HOME
  279. fi
  280. ##
  281. ## Set LD_LIBRARY_PATH
  282. ##
  283. ## On Solaris we use $ORIGIN (set in RUNPATH) instead of LD_LIBRARY_PATH 
  284. ## to locate shared libraries. 
  285. ##
  286. ## When a shared library is a symbolic link, $ORIGIN will be replaced with
  287. ## the real path (i.e., what the symbolic link points to) by the runtime
  288. ## linker.  For example, if dist/bin/libxul.so is a symbolic link to
  289. ## toolkit/library/libxul.so, $ORIGIN will be "toolkit/library" instead of "dist/bin".
  290. ## So the runtime linker will use "toolkit/library" NOT "dist/bin" to locate the
  291. ## other shared libraries that libxul.so depends on.  This only happens
  292. ## when a user (developer) tries to start firefox, thunderbird, or seamonkey
  293. ## under dist/bin. To solve the problem, we should rely on LD_LIBRARY_PATH
  294. ## to locate shared libraries.
  295. ##
  296. ## Note: 
  297. ##  We test $MOZ_DIST_BIN/*.so. If any of them is a symbolic link,
  298. ##  we need to set LD_LIBRARY_PATH.
  299. ##########################################################################
  300. moz_should_set_ld_library_path()
  301. {
  302.     [ `uname -s` != "SunOS" ] && return 0
  303.     for sharedlib in $MOZ_DIST_BIN/*.so
  304.     do
  305.         [ -h $sharedlib ] && return 0
  306.     done
  307.     return 1
  308. }
  309. if moz_should_set_ld_library_path
  310. then
  311.     LD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
  312. fi 
  313.  
  314. if [ -n "$LD_LIBRARYN32_PATH" ]
  315. then
  316.     LD_LIBRARYN32_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN32_PATH:+":$LD_LIBRARYN32_PATH"}
  317. fi
  318. if [ -n "$LD_LIBRARYN64_PATH" ]
  319. then
  320.     LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH:+":$LD_LIBRARYN64_PATH"}
  321. fi
  322. if [ -n "$LD_LIBRARY_PATH_64" ]; then
  323.     LD_LIBRARY_PATH_64=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH_64:+":$LD_LIBRARY_PATH_64"}
  324. fi
  325. #
  326. #
  327. ## Set SHLIB_PATH for HPUX
  328. SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH:+":$SHLIB_PATH"}
  329. #
  330. ## Set LIBPATH for AIX
  331. LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH:+":$LIBPATH"}
  332. #
  333. ## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin)
  334. DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH:+":$DYLD_LIBRARY_PATH"}
  335. #
  336. ## Solaris Xserver(Xsun) tuning - use shared memory transport if available
  337. if [ "$XSUNTRANSPORT" = "" ]
  338. then 
  339.         XSUNTRANSPORT="shmem" 
  340.         XSUNSMESIZE="512"
  341.         export XSUNTRANSPORT XSUNSMESIZE
  342. fi
  343.  
  344. # Disable Gnome crash dialog
  345. GNOME_DISABLE_CRASH_DIALOG=1
  346. export GNOME_DISABLE_CRASH_DIALOG
  347.  
  348. if [ "$moz_debug" -eq 1 ]
  349. then
  350.   echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME"
  351.   echo "  LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
  352.   if [ -n "$LD_LIBRARYN32_PATH" ]
  353.   then
  354.       echo "LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH"
  355.   fi
  356.   if [ -n "$LD_LIBRARYN64_PATH" ]
  357.   then
  358.       echo "LD_LIBRARYN64_PATH=$LD_LIBRARYN64_PATH"
  359.   fi
  360.   if [ -n "$LD_LIBRARY_PATH_64" ]; then
  361.       echo "LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64"
  362.   fi
  363.   if [ -n "$DISPLAY" ]; then
  364.        echo "DISPLAY=$DISPLAY"
  365.   fi
  366.   if [ -n "$FONTCONFIG_PATH" ]; then
  367.     echo "FONTCONFIG_PATH=$FONTCONFIG_PATH"
  368.   fi
  369.   if [ -n "$MOZILLA_POSTSCRIPT_PRINTER_LIST" ]; then
  370.        echo "MOZILLA_POSTSCRIPT_PRINTER_LIST=$MOZILLA_POSTSCRIPT_PRINTER_LIST"
  371.   fi
  372.   echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
  373.   echo "     LIBRARY_PATH=$LIBRARY_PATH"
  374.   echo "       SHLIB_PATH=$SHLIB_PATH"
  375.   echo "          LIBPATH=$LIBPATH"
  376.   echo "       ADDON_PATH=$ADDON_PATH"
  377.   echo "      MOZ_PROGRAM=$MOZ_PROGRAM"
  378.   echo "      MOZ_TOOLKIT=$MOZ_TOOLKIT"
  379.   echo "        moz_debug=$moz_debug"
  380.   echo "     moz_debugger=$moz_debugger"
  381.   echo "moz_debugger_args=$moz_debugger_args"
  382. fi
  383. #
  384. export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
  385. export SHLIB_PATH LIBPATH LIBRARY_PATH ADDON_PATH DYLD_LIBRARY_PATH
  386.  
  387. if [ $moz_debug -eq 1 ]
  388. then
  389.     moz_debug_program ${1+"$@"}
  390. else
  391.     moz_run_program ${1+"$@"}
  392. fi
  393.  
  394. exit $exitcode
  395.